package handlers

import (
	"github.com/gin-gonic/gin"
	"goods-master/models"
	"strconv"
)

func Create(c *gin.Context) {
	GoodsId, _ := strconv.Atoi(c.PostForm("goods_id"))

	data := models.BuyCar{
		GoodsId: GoodsId,
	}

	err := models.DB.Create(&data).Error

	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
